package com.ruoyi.common.excel;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.read.builder.ExcelReaderBuilder;
import com.alibaba.excel.read.metadata.ReadSheet;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * @author ：wang.j.f
 * @description：excelUtil
 * @date ：Created in 2021/6/14 15:01
 * @modified By：
 * @version: 1.0$
 */
@Slf4j
public class ExcelUtil {

    public static void main(String[] args) {
        ExcelReader reader = null;
        try {
            TestExcelListener testExcelListener = new TestExcelListener();
            reader = EasyExcel.read("C:\\Users\\Administrator\\Desktop\\111.xlsx", TestData.class, testExcelListener).build();
            ReadSheet readSheet = EasyExcel.readSheet(0).build();

            reader = reader.read(readSheet);
            List<TestData> dataList = testExcelListener.getDataList();
            log.info("解析数据：{}", dataList);
        } finally {
            reader.finish();
        }


    }
}
